package main

import (
	"errors"
	"strings"
)

type MsgParser struct {
	cmd  string
	data string
}

func MsgParserNew(data string) (*MsgParser, error) {
	strs := strings.Split(data, "|")
	if len(strs) == 0 {
		return nil, errors.New("error data")
	}
	mp := &MsgParser{}
	mp.cmd = strs[0]
	if len(strs) > 1 {
		mp.data = strs[1]
	}
	return mp, nil
}

func (mp *MsgParser) MsgParserCmd() string {
	return mp.cmd
}

func (mp *MsgParser) MsgParserData() string {
	return mp.data
}
